/**
*      author: Y_Yao
*      created: 2024-10-14 17:30:26
**/

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
priority_queue<int,vector<int>,greater<int>> small_heap;
priority_queue<int,vector<int>,less<int>> big_heap;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,m;
    cin >> n >> m;
    int a,b,c;
    cin >> a >> b >> c;

    int j = 1;
    while(small_heap.size() != m)
    {
        small_heap.push(a*j*j + b*j + c);
        big_heap.push(a*j*j + b*j + c);
        j++;
    }

    for(int i = 1;i < n;i++)
    {
        cin >> a >> b >> c;
        int k = 1;
        while(true)
        {
            if(a*k*k + b*k + c < big_heap.top())
            {
                big_heap.pop();
                small_heap.push(a*k*k + b*k + c);
                big_heap.push(a*k*k + b*k + c);
                k++;
            }
            else break;
        }

    }


    int t = m;
    while(t--)
    {
        cout << small_heap.top() << " ";
        small_heap.pop();
    }
    cout << endl;
    return 0;
}